<template>
  <view v-if="hasResult">
    <view class="ad-box">
      <view class="swiper-content">
        <view
          class="swiper-item"
          v-for="(item, index) in itemArr"
          :key="index"
          @click="itemTarget(item)"
        >
          <img class="swiper-img" :src="item.imageLinks" />
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import { getMallListApi } from "@/http/api";
export default {
  name: "activity",
  data() {
    return {
      hasResult: false,
      itemArr: [],
    };
  },
  mounted() {
    uni.showLoading({
      mask: true,
      title: "加载中",
    });
    // 获取ad信息
    getMallListApi({
      pageNum: 1,
      pageSize: 999,
      status: 1,
      projectId: 98,
    }).then((res) => {
      if (res.code == 200) {
        this.itemArr = res.rows;
        this.hasResult = true;
        uni.hideLoading();
      } else {
        uni.showToast({
          title: res.msg,
          icon: "none",
        });
      }
    });
  },
  methods: {
    itemTarget(item) {
      if (item.skipLinks.trim()) {
        window.location.href = item.skipLinks;
      }
    },
  },
};
</script>

<style scoped>
.ad-box {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.swiper-content {
  width: 90%;
  border-radius: 30rpx;
}
.swiper-item {
  margin-bottom: 20rpx;
}
.swiper-img {
  width: 100%;
  border-radius: 20rpx;
}
</style>
